/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package adsreis.com.Controls;


import adsreis.com.Beans.LoginBean;
import adsreis.com.acessobd.AcessoMySql;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Pauroenriki
 */
public class LoginControl {
    
    
    public LoginControl(){
        
    }
    
    
    String acesso = "SELECT USUARIO, SENHA, NOME, ACESSO, CODFUNCIONARIO FROM FUNCIONARIOS WHERE USUARIO LIKE ?";
    PreparedStatement pstm;
    ResultSet rs;
    
    
    
    
    
    
    public List<LoginBean> verificar(String nome){
        List<LoginBean> login = new ArrayList();
       try{
            AcessoMySql mysql = new AcessoMySql();
           pstm = mysql.conectar().prepareStatement(acesso);
           pstm.setString(1, nome);
           rs = pstm.executeQuery();
           LoginBean loginn = new LoginBean();
           while (rs.next()){
               loginn = new LoginBean();
               
               loginn.setUsuario(rs.getString("usuario"));
               loginn.setSenha(rs.getString("senha"));
               loginn.setNome(rs.getString("nome"));
               loginn.setIdfuncionario(rs.getString("codfuncionario"));
               loginn.setAcesso(rs.getInt("acesso"));
               login.add(loginn);              
           }
           mysql.desconectar();
        }catch (Exception e){
            e.printStackTrace();
        }
        return login;
    }
        
    
    
    
    
}
